﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace LoadTestReport
{
    public partial class ProgressWindow : Form
    {
        private BackgroundWorker statusChecker;
        public ProgressWindow()
        {
            InitializeComponent();
            
            statusChecker = new BackgroundWorker();
            statusChecker.WorkerReportsProgress = true;
            statusChecker.WorkerSupportsCancellation = true;
            statusChecker.DoWork += statusChecker_DoWork;

            statusChecker.ProgressChanged += delegate(object s, ProgressChangedEventArgs args)
            {
                progressBar.Value = args.ProgressPercentage;
                labelProgress.Text = "Retrieving results data : " +TestParent.ProgressPercentage;
            };
            statusChecker.RunWorkerAsync();
        }

        void statusChecker_DoWork(object sender, DoWorkEventArgs e)
        {
            while (true)
            {
                Thread.Sleep(50);
                statusChecker.ReportProgress(TestParent.ProgressPercentage);
            }
        }                
    }
}
